package com.JinYuan.service.impl;

import com.JinYuan.dao.AccountDao;
import com.JinYuan.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 金园
 * @create 2022/5/6
 * @Description
 * @className AccountServiceimpl
 * @packageName com.JinYuan.service.service
 */
@Component("accountService")//创建对象
@Transactional
public class AccountServiceImpl implements AccountService {
    @Autowired
    AccountDao accountDao;

//    public void setAccountDao(AccountDao accountDao) {
//        this.accountDao = accountDao;
//    }

    @Override
    public void transfer(String fromName, String toName, double money) {
        accountDao.minusAccount(fromName,money);
//        int a = 1/0;
        accountDao.plusAccount(toName,money);
    }
}
